package day07;

import java.util.Random;
import java.util.Scanner;

public class Work1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票价格");
        double price = scan.nextDouble();
        System.out.println("请输入月份");
        int month = scan.nextInt();
        System.out.println("请选择仓位:1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();
        double finalPrice = calAirPrice(price,month,type);
        if(finalPrice>0){
            System.out.println("您折后价格为"+finalPrice);
        }
 /*       //需求:----------常见面试题
        //找到2到100之间的所有素数(质数)
        //素数:除了1和它本身外，不能被其它任何自然数整数的数
       for(int num = 2;num<=100;num++){
           boolean flag = true;
           for(int i = 2;i<=num/2;i++){
               if(num%i==0){
                   flag = false;
                   break;
               }
           }
           if(flag){
               System.out.print(num+"\t");
           }
       }

  */

        //猜数字小游戏
        //训练目标: while(true)自造死循环
/*        Scanner scan = new Scanner(System.in);
        Random rand = new Random();
        int num = rand.nextInt(10)+1;
        System.out.println("开始");
        while(true){
            int guess = scan.nextInt();
            if(guess>num){
                System.out.println("大了");
            }else if(guess<num){
                System.out.println("小了");
            }else{
                System.out.println("你真牛逼");
                break;
            }
        }

 */
        /*验证码
        String code1 = yanZhengMa(6);
        System.out.println("验证码:"+code1);
    }
    public static String yanZhengMa(int len){
        String code1 = "";
        char[] abc ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w',
                'x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',
                'U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'
        };
        Random rand = new Random();
        for(int i = 1;i<=len;i++){
            int kkk = rand.nextInt(abc.length);
            code1 += abc[kkk];
        }
        return code1;

         */

    }
    /*  需求：
        机票价格按照淡季旺季、头等舱、商务舱和经济舱收费，
        输入机票原价、月份和头等舱、商务舱或经济舱，
        其中旺季（5-10月）头等舱9折，商务舱85折，经济舱8折，
        淡季（11月到来年4月）头等舱7折，商务舱65折，经济舱6折，
        最终输出机票价格
     */
    public static double calAirPrice(double price,int month,int type){
         double finalPrice = 0;
         if(month<1||month>12){
             System.out.println("月份输入错了");
             return -1;
         }
         if(type<1||type>3){
             System.out.println("舱位选择错误");
             return -1;
         }
         if(month>=5&&month<=10){
             switch(type){
                 case 1:
                     finalPrice = price*0.9;
                     break;
                 case 2:
                     finalPrice = price*0.85;
                     break;
                 case 3:
                     finalPrice = price*0.8;
                     break;
             }
         }else{
             switch(type){
                 case 1:
                     finalPrice = price*0.7;
                     break;
                 case 2:
                     finalPrice = price*0.65;
                     break;
                 case 3:
                     finalPrice = price*0.6;
                     break;
             }
         }
         return finalPrice;
    }
}
